import request from '@/utils/request'

const repository = 'b/gameTask'
const mpApi = {
    pageMyGame: repository + '/pageMyGame',
    OpenOrClose: repository + '/OpenOrClose',
    copyGame: repository + '/copyGame',
    deleteGame: repository + '/delete',
    getGameById: repository + '/getGameById',
    listMyGameSelector: repository + '/listMyGameSelector',
    gameCount: repository + '/gameCount',
    save: repository + '/save'
}

/**
 * 列出当前商户绑定的所有任务宝活动
 */
export function pageMyGame (query, filter) {
    return request({
        url: mpApi.pageMyGame,
        params: {
            query: JSON.stringify(query),
            search: JSON.stringify(filter)
        }
    })
}

export function OpenOrClose (gameId, gzhUserId, pause) {
    return request({
        url: mpApi.OpenOrClose,
        method: 'GET',
        params: { gameId, gzhUserId, pause }
    })
}

export function copyGame (gameId, gzhUserId) {
    return request({
        url: mpApi.copyGame,
        method: 'GET',
        params: { gameId, gzhUserId }
    })
}

export function deleteGame (gameId, gzhUserId) {
    return request({
        url: mpApi.deleteGame,
        method: 'GET',
        params: { gameId, gzhUserId }
    })
}

export function getGameById (gameId, gzhUserId) {
    return request({
        url: mpApi.getGameById,
        method: 'GET',
        params: { gameId, gzhUserId }
    })
}

export function listMyGameSelector (gzhUserId) {
    return request({
        url: mpApi.listMyGameSelector,
        params: { gzhUserId }
    })
}

export function gameCount () {
    return request({
        url: mpApi.gameCount
    })
}

export function save (model) {
    return request({
        url: mpApi.save,
        method: 'POST',
        data: model
    })
}

export default {
    OpenOrClose,
    pageMyGame,
    copyGame,
    deleteGame,
    getGameById,
    listMyGameSelector,
    gameCount,
    save

}
